package org.despair2D.ui.puppet 
{
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.utils.getDefinitionByName;
	import org.despair2D.debug.Logger;
	import org.despair2D.renderer.display.DisplayUtil;
	import org.despair2D.renderer.IView;
	import org.despair2D.ui.core.ComponentProxy;
	import org.despair2D.ui.Fusion;
	import org.despair2D.ui.puppet.supportClasses.PuppetComp;
	
	import org.despair2D.core.ns_despair;
	use namespace ns_despair;
	
	/**
	 * @usage
	 * 
	 * @property
	 * 		1. ◇numChildren
	 * 
	 * @method
	 * 		1. ◆addChild
	 * 		2. ◆removeChild
	 * 		3. ◆contains
	 * 		4. ◆addChildAt
	 * 		5. ◆removeChildAt
	 * 		6. ◆getChildAt
	 * 		7. ◆getChildByName
	 * 		8. ◆getChildIndex
	 * 		9. ◆setChildIndex
	 */
public class DisplayObjectContainerPuppet extends ComponentProxy
{
	
	public function DisplayObjectContainerPuppet( cacheAsBitmap:Boolean = true ) 
	{
		super();
		m_view = PuppetComp.getPuppetComp()
		m_view.proxy = this
		m_view.cacheAsBitmap = cacheAsBitmap
	}
	
	
	final public function get numChildren() : int { return m_view.numChildren }
	
	
	final public function addChild( child:DisplayObject ) : DisplayObject
	{
		return m_view.addChild(child)
	}
	
	final public function removeChild( child:DisplayObject ) : DisplayObject
	{
		return m_view.removeChild(child)
	}
	
	final public function addChildAt ( child:DisplayObject, index:int) : DisplayObject
	{
		return m_view.addChildAt(child, index)
	}
	
	final public function contains( child:DisplayObject ) : Boolean
	{
		return m_view.contains(child)
	}
	
	final public function removeChildAt ( child:DisplayObject, index:int) : DisplayObject
	{
		return m_view.removeChildAt(index)
	}
	
	final public function getChildAt ( index:int) : DisplayObject
	{
		return m_view.getChildAt(index)
	}
	
	final public function getChildByName( name:String ) : DisplayObject
	{
		return m_view.getChildByName(name)
	}
	
	final public function getChildIndex( child:DisplayObject ) : int
	{
		return m_view.getChildIndex(child)
	}
	
	final public function setChildIndex( child:DisplayObject, index:int ) : void
	{
		m_view.setChildIndex(child, index)
	}
	
	
	final override ns_despair function get view() : IView
	{
		return m_view;
	}
	
	final override ns_despair function get shell() : DisplayObject
	{
		return m_view;
	}
	
	override ns_despair function dispose() : void
	{
		DisplayUtil.clear(m_view)
		super.dispose();
		m_view.recycle()
		m_view = null
	}
	
	
	ns_despair var m_view:PuppetComp;
}
}